﻿<!--
Author : K.F.Storm
Email : yk000123 at sina.com
Website : http://www.kfstorm.com	
-->
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:resx="clr-namespace:DoubanFM.Resources"
	xmlns:local="clr-namespace:DoubanFM">

	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="/DoubanFM;component/Theme.xaml"/>
	</ResourceDictionary.MergedDictionaries>

	<local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
	
	<ControlTemplate x:Key="WindowBaseTemplate" TargetType="{x:Type Window}">
		<Grid x:Name="MainPanel" Background="{TemplateBinding Background}">
			<ContentPresenter/>
		</Grid>
	</ControlTemplate>
	<Style TargetType="{x:Type local:WindowBase}">
		<Setter Property="WindowStyle" Value="None"/>
		<Setter Property="ResizeMode" Value="NoResize"/>
		<Setter Property="SizeToContent" Value="WidthAndHeight"/>
		<Setter Property="Background" Value="{x:Null}"/>
		<Setter Property="Foreground" Value="White"/>
		<Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
		<Setter Property="Template" Value="{StaticResource WindowBaseTemplate}"/>
	</Style>

	<Style x:Key="CloseStyle" BasedOn="{StaticResource CustomButtonStyle}" TargetType="{x:Type Button}">
        <Setter Property="ToolTip" Value="{x:Static resx:Resources.CloseButton}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Viewbox>
						<Canvas Width="256" Height="256" Clip="F1 M 0,0L 256,0L 256,256L 0,256L 0,0" Background="{TemplateBinding Background}">
							<Path Width="214.627" Height="214.627" Canvas.Left="20.6863" Canvas.Top="20.6863" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="M 20.6863,212.686L 105.373,128L 20.6863,43.3137L 43.3137,20.6863L 128,105.373L 212.686,20.6863L 235.314,43.3137L 150.627,128L 235.314,212.686L 212.686,235.314L 128,150.627L 43.3137,235.314L 20.6863,212.686 Z "/>
						</Canvas>
					</Viewbox>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<ControlTemplate x:Key="ChildWindowBaseTemplate" TargetType="{x:Type local:ChildWindowBase}">
		<Grid x:Name="MainPanel" Background="{TemplateBinding Background}">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition/>
			</Grid.RowDefinitions>
			<Grid Height="20" Margin="5">
				<Grid.ColumnDefinitions>
					<ColumnDefinition/>
					<ColumnDefinition Width="Auto"/>
				</Grid.ColumnDefinitions>
				<TextBlock FontSize="14" Foreground="White" Text="{TemplateBinding Title}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
				<Button x:Name="PART_Close" HorizontalAlignment="Right" Style="{StaticResource CloseStyle}"/>
			</Grid>
			<ContentPresenter Grid.Row="1"/>
		</Grid>
	</ControlTemplate>
	<Style BasedOn="{StaticResource {x:Type local:WindowBase}}" TargetType="{x:Type local:ChildWindowBase}">
		<Setter Property="Background" Value="{Binding Owner.Background}"/>
		<Setter Property="ShowInTaskbar" Value="False"/>
		<Setter Property="Template" Value="{StaticResource ChildWindowBaseTemplate}"/>
	</Style>
	
	
	<Style x:Key="ClearHotKeyStyle" BasedOn="{StaticResource CloseStyle}" TargetType="{x:Type Button}">
        <Setter Property="ToolTip" Value="{x:Static resx:Resources.Clear}"/>
    </Style>
	<Style TargetType="{x:Type local:HotKeySettingControl}">
		<Setter Property="Foreground" Value="White"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:HotKeySettingControl}">
					<Grid Background="{TemplateBinding Background}">
						<Grid.ColumnDefinitions>
							<ColumnDefinition/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<TextBox x:Name="PART_HotKeyText" Margin="10,0" IsReadOnly="True" IsReadOnlyCaretVisible="True"/>
						<Button x:Name="PART_Clear" Grid.Column="1" Style="{StaticResource ClearHotKeyStyle}"/>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="Padding" Value="2"/>
	</Style>
	
	<DrawingBrush x:Key="TransparentBackgroundBrush" TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,16,16">
		<DrawingBrush.Drawing>
			<DrawingGroup>
				<GeometryDrawing Brush="White">
					<GeometryDrawing.Geometry>
						<RectangleGeometry Rect="0,0,1,1"/>
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
				<GeometryDrawing Brush="LightGray">
					<GeometryDrawing.Geometry>
						<RectangleGeometry Rect="0,0,0.5,0.5"/>
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
				<GeometryDrawing Brush="LightGray">
					<GeometryDrawing.Geometry>
						<RectangleGeometry Rect="0.5,0.5,0.5,0.5"/>
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
			</DrawingGroup>
		</DrawingBrush.Drawing>
	</DrawingBrush>
	
	<Style x:Key="SliderRepeatButtonStyle"
		 TargetType="{x:Type RepeatButton}">
		<Setter Property="OverridesDefaultStyle" Value="true"/>
		<Setter Property="IsTabStop" Value="false"/>
		<Setter Property="Focusable" Value="false"/>
		<Setter Property="IsHitTestVisible" Value="False"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Border Background="{TemplateBinding Background}"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<Style x:Key="VerticalSlideThumbStyle" TargetType="{x:Type Thumb}">
		<Setter Property="Focusable" Value="false"/>
		<Setter Property="OverridesDefaultStyle" Value="true"/>
		<Setter Property="Foreground" Value="Black"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto"/>              	
							<ColumnDefinition/>              	
							<ColumnDefinition Width="Auto"/>              	
						</Grid.ColumnDefinitions>
						<Path x:Name="LeftArrow" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="F1 M 276.761,316L 262.619,307.835L 262.619,324.165L 276.761,316 Z " RenderTransformOrigin="0.5,0.5" Width="8" Height="16" VerticalAlignment="Center"/>
						<Path x:Name="RightArrow" Grid.Column="2" Stretch="Fill" Fill="{TemplateBinding Foreground}" Data="F1 M 276.761,316L 262.619,307.835L 262.619,324.165L 276.761,316 Z " RenderTransformOrigin="0.5,0.5" Width="8" Height="16" VerticalAlignment="Center" >
							<Path.RenderTransform>
								<TransformGroup>
									<ScaleTransform/>
									<SkewTransform/>
									<RotateTransform Angle="-180"/>
								</TransformGroup>
							</Path.RenderTransform>
						</Path>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type local:ColorSpectrumSlider}">
		<Setter Property="Orientation" Value="Vertical"/>
		<Setter Property="Minimum" Value="0"/>
		<Setter Property="Maximum" Value="359.9999999999"/>
		<Setter Property="IsDirectionReversed" Value="True" />
		<Setter Property="BorderBrush" Value="Black"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:ColorSpectrumSlider}">
					<Grid ClipToBounds="True">
						<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
							<Grid>
								<Rectangle x:Name="PART_Spectrum">
									<Rectangle.Fill>
										<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
											<GradientStop Offset="0.00000000000" Color="#FFFF0000"/>
											<GradientStop Offset="0.16666666667" Color="#FFFFFF00"/>
											<GradientStop Offset="0.33333333333" Color="#FF00FF00"/>
											<GradientStop Offset="0.50000000000" Color="#FF00FFFF"/>
											<GradientStop Offset="0.66666666667" Color="#FF0000FF"/>
											<GradientStop Offset="0.83333333333" Color="#FFFF00FF"/>
											<GradientStop Offset="1.00000000000" Color="#FFFF0000"/>
										</LinearGradientBrush>                    	
									</Rectangle.Fill>                     
								</Rectangle>
								<Track x:Name="PART_Track" Margin="0,-8">
									<Track.DecreaseRepeatButton>
										<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.DecreaseLarge"/>
									</Track.DecreaseRepeatButton>
									<Track.IncreaseRepeatButton>
										<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.IncreaseLarge"/>
									</Track.IncreaseRepeatButton>
									<Track.Thumb>
										<Thumb x:Name="PART_Thumb" Style="{StaticResource VerticalSlideThumbStyle}" Foreground="{TemplateBinding BorderBrush}"/>
									</Track.Thumb>
								</Track>
							</Grid>
						</Border>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="ArgbSliderStyle" BasedOn="{StaticResource {x:Type Slider}}" TargetType="{x:Type Slider}">
		<Setter Property="Minimum" Value="0"/>
		<Setter Property="Maximum" Value="255"/>
		<Setter Property="SmallChange" Value="1"/>
		<Setter Property="LargeChange" Value="10"/>
		<Setter Property="VerticalAlignment" Value="Center"/>
		<Setter Property="Margin" Value="2"/>
		<Setter Property="Background" Value="#0033C8B0"/>
	</Style>
	<Style x:Key="ArgbAndHexTextBoxStyle" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
		<Setter Property="Height" Value="24"/>
		<Setter Property="VerticalAlignment" Value="Center"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Margin" Value="2,2,0,2"/>
		<Style.Triggers>
			<Trigger Property="Validation.HasError" Value="True">
				<Setter Property="BorderThickness" Value="2"/>
				<Setter Property="BorderBrush" Value="Red"/>
			</Trigger>
		</Style.Triggers>
	</Style>
	<Style TargetType="{x:Type local:ColorPicker}">
		<Setter Property="BorderBrush" Value="Black"/>
		<Setter Property="BorderThickness" Value="0"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:ColorPicker}">
					<Border Background="{TemplateBinding Background}"
						BorderBrush="{TemplateBinding BorderBrush}"
						BorderThickness="{TemplateBinding BorderThickness}">
						<Grid ClipToBounds="True" MinHeight="150">
							<Grid.ColumnDefinitions>
								<ColumnDefinition MinWidth="150"/>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<Border BorderBrush="Black" BorderThickness="1">
								<Canvas x:Name="PART_ColorShadeCanvas" ClipToBounds="True">
									<Rectangle Width="{Binding ActualWidth, ElementName=PART_ColorShadeCanvas}" Height="{Binding ActualHeight, ElementName=PART_ColorShadeCanvas}">
										<Rectangle.Fill>
											<SolidColorBrush Color="{Binding SelectedColor, ElementName=PART_ColorSpectrumSlider}"/>
										</Rectangle.Fill>
									</Rectangle>
									<Rectangle Width="{Binding ActualWidth, ElementName=PART_ColorShadeCanvas}" Height="{Binding ActualHeight, ElementName=PART_ColorShadeCanvas}">
										<Rectangle.Fill>
											<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
												<GradientStop Offset="0" Color="White"/>
												<GradientStop Offset="1" Color="Transparent"/>
											</LinearGradientBrush>
										</Rectangle.Fill>
									</Rectangle>
									<Rectangle Width="{Binding ActualWidth, ElementName=PART_ColorShadeCanvas}" Height="{Binding ActualHeight, ElementName=PART_ColorShadeCanvas}">
										<Rectangle.Fill>
											<LinearGradientBrush StartPoint="0,1" EndPoint="0, 0">
												<GradientStop Offset="0" Color="#FF000000"/>
												<GradientStop Offset="1" Color="#00000000"/>
											</LinearGradientBrush>
										</Rectangle.Fill>
									</Rectangle>
									<Grid x:Name="PART_ColorShadeSelector" Width="10" Height="10" IsHitTestVisible="False">
										<Ellipse StrokeThickness="3" Stroke="White"/>
										<Ellipse StrokeThickness="1" Stroke="Black" Margin="1" />
									</Grid>
								</Canvas>
							</Border>
							<local:ColorSpectrumSlider x:Name="PART_ColorSpectrumSlider" Grid.Column="1" BorderBrush="Black" BorderThickness="0,1,1,1" Width="24"/>
							<Border Grid.Column="2" Width="180" BorderThickness="0,1,1,1" BorderBrush="Black">
								<Grid Margin="5">
									<Grid.RowDefinitions>
										<RowDefinition/>
										<RowDefinition/>
										<RowDefinition/>
										<RowDefinition/>
										<RowDefinition/>
									</Grid.RowDefinitions>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="16"/>
										<ColumnDefinition/>
										<ColumnDefinition Width="36"/>
									</Grid.ColumnDefinitions>
									<TextBlock Grid.Row="0" VerticalAlignment="Center"><Run Text="R"/></TextBlock>
									<Slider Grid.Row="0" Grid.Column="1" Style="{StaticResource ArgbSliderStyle}" Value="{Binding R, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
									<TextBox x:Name="PART_TextBoxR" Grid.Row="0" Grid.Column="2" Text="{Binding R, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" Style="{StaticResource ArgbAndHexTextBoxStyle}"/>
									<TextBlock Grid.Row="1" VerticalAlignment="Center"><Run Text="G"/></TextBlock>
									<Slider Grid.Row="1" Grid.Column="1" Style="{StaticResource ArgbSliderStyle}" Value="{Binding G, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
									<TextBox x:Name="PART_TextBoxG" Grid.Row="1" Grid.Column="2" Text="{Binding G, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" Style="{StaticResource ArgbAndHexTextBoxStyle}"/>
									<TextBlock Grid.Row="2" VerticalAlignment="Center"><Run Text="B"/></TextBlock>
									<Slider Grid.Row="2" Grid.Column="1" Style="{StaticResource ArgbSliderStyle}" Value="{Binding B, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
									<TextBox x:Name="PART_TextBoxB" Grid.Row="2" Grid.Column="2" Text="{Binding B, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" Style="{StaticResource ArgbAndHexTextBoxStyle}"/>
									<TextBlock Grid.Row="3" VerticalAlignment="Center" Visibility="{Binding Visibility, ElementName=PART_TextBoxA}"><Run Text="A"/></TextBlock>
									<Slider Grid.Row="3" Grid.Column="1" Style="{StaticResource ArgbSliderStyle}" Value="{Binding A, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Visibility, ElementName=PART_TextBoxA}"/>
									<TextBox x:Name="PART_TextBoxA" Grid.Row="3" Grid.Column="2" Text="{Binding A, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" Style="{StaticResource ArgbAndHexTextBoxStyle}" Visibility="{Binding IsAlphaEnabled, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BoolToVisibilityConverter}}"/>
									<Grid Grid.Row="4" Grid.ColumnSpan="3" Margin="0,2,0,0">
										<Grid.ColumnDefinitions>
											<ColumnDefinition/>
											<ColumnDefinition Width="80"/>
										</Grid.ColumnDefinitions>
										<Border Grid.Column="0" Background="{StaticResource TransparentBackgroundBrush}">
											<Border MinHeight="20">
												<Border.Background>
													<SolidColorBrush Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}"/>
												</Border.Background>
											</Border>			
										</Border>
										<TextBox x:Name="PART_TextBoxHexString" Grid.Column="1" Margin="4,0,0,0" Height="20" Text="{Binding HexString, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True}" Style="{StaticResource ArgbAndHexTextBoxStyle}"/>
									</Grid>
								</Grid>
							</Border>
						</Grid>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="Foreground" Value="White"/>
	</Style>

	<Style TargetType="{x:Type local:FontPicker}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:FontPicker}">
					<ComboBox x:Name="PART_FontComboBox" IsEditable="True" FontFamily="{TemplateBinding Font}">
						<ComboBox.ItemsPanel>
							<ItemsPanelTemplate>
								<VirtualizingStackPanel/>
							</ItemsPanelTemplate>
						</ComboBox.ItemsPanel>
						<ComboBox.ItemTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding}" FontFamily="{Binding}"/>
							</DataTemplate>
						</ComboBox.ItemTemplate>
					</ComboBox>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
